package com.baizhi.hospital.service.impl;

import com.baizhi.hospital.dao.TriageDao;
import com.baizhi.hospital.entity.Triage;
import com.baizhi.hospital.entity.TriageDTO;
import com.baizhi.hospital.service.TriageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class TriageServiceImpl implements TriageService {
	@Autowired(required = false)
	private TriageDao triageDao;
	@Override
	public Map addTriage(Triage triage) {
		int i = triageDao.addTriage(triage);
		Map map = new HashMap();
		if(i > 0){
			map.put("isAdd","挂号成功,请前往分诊管理对应的科室查看信息");
		}else{
			map.put("isAdd","挂号失败");
		}
		return map;
	}

	@Override
	public Map selectTriageInfo(int page, int limit,int departmentId) {
		int offset = (page-1)*limit;
		Map map = new HashMap();
		List<TriageDTO> triageDTOS = triageDao.selectTriageInfo(offset, limit, departmentId);
		int count = triageDao.selectCount(departmentId);
		 map.put("data",triageDTOS);
		 map.put("count",count);
		 map.put("code",0);
		map.put("msg","");
		return map;
	}

	@Override
	public Map updateTriage(Triage triage) {
		Map map = new HashMap();

		int i = triageDao.updateTriage(triage);
		if(i > 0 ){
			map.put("isUpdate","诊断成功");
		}else{
			map.put("isUpdate","诊断失败");
		}
		return map;
	}
}
